package com.ecarx.camera.data;

import android.graphics.Bitmap;

import com.ecarx.camera.constant.Constants;

/**
 * 缩略图数据
 */
public class ThumbnailData {

    /**
     * 摄像头朝向（内部摄像头或DVR）
     */
    private @Constants.FacingType int facingType;

    /**
     * 判断是否为视频缩略图
     */
    private boolean isVideo = false;

    /**
     * DVR的录制类型（一般循环录像或紧急录像）
     */
    private int dvrRecordingType = -1;

    /**
     * 缩略图Bitmap数据
     */
    private Bitmap bitmap;

    /**
     * 相册数据的Id
     */
    private int galleryId;

    public int getFacingType() {
        return facingType;
    }

    public ThumbnailData setFacingType(int facingType) {
        this.facingType = facingType;
        return this;
    }

    public boolean isVideo() {
        return isVideo;
    }

    public ThumbnailData setVideo(boolean video) {
        isVideo = video;
        return this;
    }

    public int getDvrRecordingType() {
        return dvrRecordingType;
    }

    public ThumbnailData setDvrRecordingType(int dvrRecordingType) {
        this.dvrRecordingType = dvrRecordingType;
        return this;
    }

    public Bitmap getBitmap() {
        return bitmap;
    }

    public ThumbnailData setBitmap(Bitmap bitmap) {
        this.bitmap = bitmap;
        return this;
    }

    public int getGalleryId() {
        return galleryId;
    }

    public void setGalleryId(int galleryId) {
        this.galleryId = galleryId;
    }

    public void recycle() {
        if (bitmap != null && !bitmap.isRecycled()) {
            bitmap.recycle();
            bitmap = null;
        }
    }

    @Override
    public String toString() {
        return "ThumbnailData{" +
                "facingType=" + facingType +
                ", isVideo=" + isVideo +
                ", dvrRecordingType=" + dvrRecordingType +
                ", bitmap=" + bitmap +
                ", galleryId=" + galleryId +
                '}';
    }
}
